package edu.gatech.oad.antlab.m7final;
/**
 * This class represents the Wagon object, and has a Pace attribute
 *
 * @author Akbar Dhannani
 * @version 1.0.0.0
 */
public class Wagon {



	private static Pace pace;
	private static Settler[] people;
	private static Player player;

	private static String ration;
	private static Wagon singletonWagon;

	private static InventoryController invControl;


	private static int money;




	/**
	 * The constructor creates an array of Settle objects and adds 4 settler objects to it
	 * It also sets the initial pace of the wagon
	 * @param one Settler one
	 * @param two Settler two
	 * @param three Settler three
	 * @param four Settler four
	 * @param pace Pace of the wagon
	 * A private Constructor prevents any other class from instantiating the Singleton. 
	 */
	private Wagon(Object one,Object two,Object three,Object four, Pace pace, Player player, String ration){
		people = new Settler[4];
		people[0] = (Settler)one;
		people[1]= (Settler)two;
		people[2]= (Settler)three;
		people[3]=(Settler)four;
		Wagon.player = player;
		Wagon.pace = pace;
		Wagon.ration=ration;
		money = 0;
		if(player.getProfession().equals(Profession.FARMER)){
			money = 400;
		}
		if(player.getProfession().equals(Profession.CARPENTER)){
			money = 800;
		}
		if(player.getProfession().equals(Profession.BANKER)){
			money = 1600;
		}
		invControl = new InventoryController(money);
	}

	public static synchronized Wagon getWagon(Object one,Object two,Object three,Object four, Pace pace, Player player, String ration) {
		if (singletonWagon == null) {
			singletonWagon = new Wagon(one, two, three, four, pace, player, ration);
		}
		return singletonWagon;
	}

	public static synchronized Wagon getWagon() {
		return singletonWagon;
	}
	public Object clone() throws CloneNotSupportedException {
		throw new CloneNotSupportedException();
	}


	/*
	 * Returns a string representation of the data stored in the wagon
	 * @return A string holding the data stored in the wagon. 
	 */
	public String toString(){
		String str = "";
		str += "Settler names and rations: ";
		for(Settler curr: people){
			str += "Setter: " + curr.getName() + " Ration: " + "\n";
		}
		str += "Pace: " + pace;
		str += "\nPlayer data: " + player.getName() + " Ration:" + " Profession" + player.getProfession();
		return str;
	}

	/**
	 * Getter method for the player
	 * @return The player in the wagon
	 */
	public static Player getPlayer(){
		return player;
	}
	
	public static Settler getSettlerOne(){
		return people[0];
	}
	
	public static Settler getSettlerTwo(){
		return people[1];
	}
	
	public static Settler getSettlerThree(){
		return people[2];
	}
	
	public static Settler getSettlerFour(){
		return people[3];
	}
	
	/**
	 * Getter method for the array of settlers
	 * @return The array of settlers in the wagon
	 */
	public Settler[] getPeople(){
		return people;
	}

	/**
	 * Getter method for the pace
	 * @return The current pace of the journey
	 */
	public static Pace getPace(){
		return pace;
	}

	/**
	 * Setter method for the pace
	 * @param pace The desired pace for the journey
	 */

	public static void setPace(Pace p){
		pace = p;
	}
	
	
	/**
	 * Getter for the inventory controller
	 * @return 
	 */
	public static InventoryController getInventoryController(){
		return invControl;
	}

	/**
	 * @return the ration
	 */
	public static String getRation() {
		return ration;
	}

	/**
	 * @param ration the ration to set
	 */
	public static void setRation(String ration) {
		Wagon.ration = ration;
	}

}


